home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
vernon.zip
/
SINOFX.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-07-23
|
1KB
|
57 lines
program SINOFX;
{I+}
{ This program calculates sin(x) using the Taylor's series
expansion:
i (2i + 1)
sin(x) = (-1) x
---------------
(2i + 1) !
by continuing to calculate a new term until the value has
been calculated to within an accuracy of .0001 }
uses crt;
var x :real; I, Q : integer; Sum, Y : real; TERM1 : real;
{$I Power.pas }
{$I Neg1.pas }
{$I Xval.pas }
{$I Fact.pas }
{$I Term.pas }
begin
ClrScr;
HighVideo;
TextColor(12);
write('Enter a value in degrees for x to find the value sin(x): ');
readln (x);
Q := trunc(X / 360);
x := x - Q * 360;
x := x * pi /180;
sum := 0;
I := 0;
{ while x <> 0 do begin} if x = 0 then sum := 0 else
while ABS (term(x,i)) > 0.0001 do begin
Sum := Sum + Term(X,I);
term1 := term(x,i);
{WRITELN('The value of term is: ', TERM1);}
I := I + 1
end; {while accuracy}
{ end; while x }
writeln;
writeln('Sin(x) = ', Sum:12:4);
LowVideo;
end.